package com.lfx.concurrent;

import java.util.Random;
import java.util.concurrent.CountDownLatch;

/**
 * @author 李逢喜
 * create 2021/8/2
 */
public class MyThread2 extends Thread{

    private final CountDownLatch countDownLatch;

    private final Random random = new Random();

    public MyThread2(CountDownLatch countDownLatch,String name) {
        super(name);
        this.countDownLatch = countDownLatch;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(random.nextInt(2000));
            System.out.println(super.getName()+"运行结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        countDownLatch.countDown();
    }
}
